import { CurrencyEnum } from '@/enums/currency.ts'
import { GetUserBalance, GetUserWalletAddress } from '@/api/wallet-type'
import { NumericString } from '@/types/common.ts'

export type ChannelItemType = {
	icon: any
	name: any
	paymentMethodCode: any
	paymentMethod: any
	merchantList: any
	merchantInfo: any
	networks?: any
}

export type ChannelListType = Array<ChannelItemType>

export type CardsItemType = {
	id: any
	bankIcon: any
	bankName: any
	cardNumber: any
}

export type CardsListType = Array<CardsItemType>

export type ChannelInfoType = {
	channelList: any
	tellMsg?: any
}

export type NetworkAddressItem = {
	cpn: string
	cpnDisplay: string
	memo: string
	thirdAssetId: string
	walletAddress: string
}

export type BalanceItem = {
	appName: string
	assetType: number
	currency: CurrencyEnum
	currentAmount: string | number
	freeAmount: string
	userAssets: NetworkAddressItem[]
}

export type BalanceList = BalanceItem[]

export enum WalletConfigEnum {
	displayCryptoInFiat = 'displayCryptoInFiat',
	hideZeroBalance = 'hideZeroBalance',
	selectedCryptoCurrency = 'selectedCryptoCurrency',
	selectedFiatCurrency = 'selectedFiatCurrency',
	sortedCurrency = 'sortedCurrency'
}

export type WalletConfig = {
	[WalletConfigEnum.displayCryptoInFiat]: boolean
	[WalletConfigEnum.hideZeroBalance]: boolean
	[WalletConfigEnum.selectedCryptoCurrency]: CurrencyEnum
	[WalletConfigEnum.selectedFiatCurrency]: CurrencyEnum
	[WalletConfigEnum.sortedCurrency]: CurrencyEnum[]
	expandFiat: boolean
	expandCrypto: boolean
}

export type UpdateWalletConfig<T extends keyof WalletConfig> = {
	confCode: T
	confValue: WalletConfig[T]
}

export type ExchangeRate = {
	[key in CurrencyEnum]: { [key in CurrencyEnum]: string }
}

export type CurrencyItem = {
	appName: string
	currency: CurrencyEnum
	currencySymbol: string
	icon: string
}

export type CreateWallet = {
	params: {
		currency: CurrencyEnum
		thirdAssetId: string
	}
	result: NetworkAddressItem
}

export enum PatchWalletEnum {
	balanceItem = 'balanceItem',
	balanceList = 'balanceList',
	addressItem = 'addressItem',
	addressList = 'addressList'
}

export type PatchWallet = {
	[PatchWalletEnum.balanceItem]: GetUserBalance['resultItem']
	[PatchWalletEnum.balanceList]: GetUserBalance['result']
	[PatchWalletEnum.addressItem]: GetUserWalletAddress['resultItem']
	[PatchWalletEnum.addressList]: GetUserWalletAddress['result']
}

export const WalletAction: any = {
	recharge: {
		id: 1,
		name: 'transaction.recharge',
		// '存款'
		icon: 'recharge1'
	},
	withdraw: {
		id: 2,
		name: 'transaction.withdraw',
		// name: '提款',
		icon: 'withdraw'
	}
}

export type FiatPayChannelList = FiatPayChannel[]
export type FiatPayChannel = {
	currency: CurrencyEnum
	payTypeList: FiatPayTypeList
}
export type FiatPayTypeList = FiatPayType[]
export type FiatPayType = {
	payTypeId: number
	payTypeName: string
	payMethodList: FiatPayMethodList
}
export type FiatPayMethodList = FiatPayMethod[]
export type FiatPayMethod = {
	appIcon: string
	appSort: number
	assetId: CurrencyEnum
	autoDisable: 1 | 2
	channelName: string
	dailyAmount: NumericString
	enableTime: string[]
	feePlatform: any[]
	id: number
	inputField: string[]
	maxAmount: NumericString
	merchantId: number
	minAmount: NumericString
	payMethodId: number
	payMethodName: string
	payTypeId: number
	payTypeName: string
	spendTime: number
	symbol: CurrencyEnum
	timeout: number
	vipLevel: string[]
	whitelist: string[]
}

export type FaitWithdrawFeeList = FaitWithdrawFee[]
export type FaitWithdrawFee = {
	maxAmount: NumericString
	minAmount: NumericString
	fixed: NumericString
	percent: NumericString
	assetId: CurrencyEnum
}
